package com.chen.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.chen.entity.Account;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.math.BigDecimal;

@Mapper
public interface AccountMapper extends BaseMapper<Account> {

    @Update("UPDATE t_account set amount = amount + #{amount},frozen_amount = frozen_amount-#{amount} WHERE id = #{accountId} and frozen_amount > 0")
    void transferIn(@Param("accountId") int accountId, @Param("amount") BigDecimal amount);

    @Update("UPDATE t_account set frozen_amount = frozen_amount-#{amount} WHERE id = #{accountId} and frozen_amount > 0")
    void unFreezeAmount2(@Param("accountId") int accountId, @Param("amount")BigDecimal amount);
}
